<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /* 
        第一种，字符串本质上就是数组,可以用reverse，细节在于，还是需要通过
        split转化为数组的      console.log(s.split("").reverse());
        第二种:通过双指针
        */
      var reverseString = function (s) {
        let left = 0;
        let right = s.length - 1;
        s = s.split("");
        while (left <= right) {
          [s[left], s[right]] = [s[right], s[left]];
          left++;
          right--;
        }
        console.log(s);
      };
      reverseString("abcd");
    </script>
  </body>
</html>
